Skip to content

Conversation

@nian0114
Copy link
Contributor

  • Implemented _parse_types in MySQL.Parser to consume the ZEROFILL token and store it in the DataType expression.
  • Updated datatype_sql in MySQL.Generator to output ZEROFILL when the attribute is present.

This fixes parsing errors encountered when processing legacy MySQL schemas containing numeric columns with the zerofill property.

@nian0114
Copy link
Contributor Author

Fixes #6399

@georgesittas georgesittas linked an issue Nov 24, 2025 that may be closed by this pull request
@nian0114 nian0114 force-pushed the main branch 2 times, most recently from 0d7321a to cd8b35c Compare November 25, 2025 15:07
Comment on lines 35 to 38
class ZeroFill(exp.Expression):
pass


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't define new expression types outside of expressions.py. Please move this to said module and define it as ZeroFillColumnConstraint(ColumnConstraint): arg_types = {}, instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha ok. i will do it later.

exp.Year: _remove_ts_or_ds_to_date(),
exp.UtcTimestamp: rename_func("UTC_TIMESTAMP"),
exp.UtcTime: rename_func("UTC_TIME"),
ZeroFill: lambda self, e: "ZEROFILL",
Copy link
Collaborator

@georgesittas georgesittas Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generation for ZeroFill needs to be moved to the base Generator class, otherwise doing sql() on a MySQL AST will raise, if it contains a ZEROFILL constraint.

This fixes parsing errors encountered when processing legacy MySQL schemas containing numeric columns with the zerofill property.
Copy link
Collaborator

@georgesittas georgesittas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thank you for the swift iterations!

@georgesittas georgesittas merged commit 8caec6e into tobymao:main Nov 25, 2025
8 checks passed
georgesittas pushed a commit that referenced this pull request Nov 25, 2025
This fixes parsing errors encountered when processing legacy MySQL schemas containing numeric columns with the zerofill property.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MySQL ZEROFILL column attribute error

3 participants